<?php
$page = $_GET['page'];
if($page=='library')
{

    require('db_connection.php');
    $libraryCtr = $_GET['libraryCtr'];
    for($ctr=0;$ctr < $libraryCtr+1; $ctr++ )
    {
        $query = "DELETE FROM tbllibrary WHERE libraryNo='$libraryName[$ctr]'";
        $result = mysql_query($query);
        //echo $query;
    }
    ///$result = mysql_query($query);

    if($result){

    //echo("Record sucessfully deleted.");
    echo"<script> alert('Record Successfully Deleted.');</script>";

    echo"'<script>document.location.href='libprofileview.php'</script>'";
    }else{
       echo"<script> alert('Delete Failed!');</script>";
    }
    mysql_close();
}

else if ($page=='catalog')
{
    require('db_connection.php');
    $catalogCtr = $_GET['catalogCtr'];
    for($ctr=1;$ctr < $catalogCtr+1; $ctr++ )
    {
        $query = "DELETE FROM tblcollection WHERE materialID LIKE '$mat[$ctr]'";
        $result = mysql_query($query);
        //echo $mat[$ctr];
    }
    //$result = mysql_query($query);

    if($result){

    echo"<script> alert('Record Successfully Deleted.');</script>";

    echo"'<script>document.location.href='catalogentry.php'</script>'";
    }else{
       echo"<script> alert('Delete Failed!');</script>";
    }
    
}
if($page=='client')
{
   require ('db_connection.php');
  //$user[userID] = $_POST[''];
  //$ctr1 = $_GET['ctr'];
  $clientCtr = $_GET['clientCtr'];

  for ($ctr=1; $ctr<$clientCtr+1; $ctr++)
  {
    $query = "DELETE FROM tblclient WHERE userID='$ser[$ctr]'";
    $result = mysql_query($query);
    echo $query;
  }

    
    //echo $result;
    if($result)
    {
      echo"<script> alert('Record Successfully Deleted.');</script>";
      echo "<script>document.location.href='client.php'</script>";
    }
    else
    {
      echo"<script> alert('Delete Failed!');</script>";
    }
}

if($page=='admin')
{
   require ('db_connection.php');
  //$user[userID] = $_POST[''];
  //$ctr1 = $_GET['ctr'];
  $adminCtr = $_GET['adminCtr'];

  for ($ctr=1; $ctr<$adminCtr+1; $ctr++)
  {
    $query = "DELETE FROM tbladmin WHERE adminID='$admin[$ctr]'";
    $result = mysql_query($query);
    echo $admin[$ctr];
   // echo $query;

  }
    if($result)
    {
      echo"<script> alert('Successfully Deleted!!');</script>";
      echo "<script>document.location.href='adminresult.php'</script>";
    }
    else
    {
      echo"<script> alert('Delete Failed!');</script>";
    }
}

if($page=='news')
{
   require ('db_connection.php');
  //$user[userID] = $_POST[''];
  //$ctr1 = $_GET['ctr'];
  $newsCtr = $_GET['newsCtr'];


  for ($ctr=1; $ctr<$newsCtr+1; $ctr++)
  {
    $query = "DELETE FROM tblnews WHERE newsID='$news[$ctr]'";
    $result = mysql_query($query);
    echo $news[$ctr];
   // echo $query;

  }
    if($result)
    {
      echo"<script> alert('Successfully Deleted!!');</script>";
      echo "<script>document.location.href='viewdelete.php?page=news'</script>";
    }
    else
    {
      echo"<script> alert('Delete Failed!');</script>";
    }
}
?>
